﻿using System.Collections.Generic;
using DevExpress.Xpf.Accordion;
using DevExpress.Xpf.Docking;
using DevExpress.Xpf.PropertyGrid;
using OneStress.PropertyNodes;
using orm.Models;
using System.Linq;
using DevExpress.Mvvm;
using System;
using System.ComponentModel;
using DevExpress.Xpf.Core;

using System.Collections.ObjectModel;
using DevExpress.Mvvm.DataAnnotations;

namespace OneStress.ViewModels
{

    public class PropertiesViewModel : PanelWorkspaceViewModel
    {
        public PropertiesViewModel() {
            DisplayName = "Properties";
            Glyph = Images.PropertiesWindow;

            //todo：Messenger应该用上参数Token，作为操作实体数据的一个标识
            Messenger.Default.Register<OrgEntity>(this, OnPropChanged);
            OrgPropNode = PropNodeFactory.Instance.GetNode(OrgnizationManager.Instance.Orgnizations.FirstOrDefault());
        }

        private void OnPropChanged(OrgEntity org)
        {
            OrgPropNode = PropNodeFactory.Instance.GetNode(OrgnizationManager.Instance.CurrentOrg);
     
        }

        public AbstractPropNode OrgPropNode
        {
            get { return GetProperty(() => OrgPropNode); }
            set { SetProperty(() => OrgPropNode, value); }
        }


        protected override string WorkspaceName { get { return "RightHost"; } }

    
    }
  
}
